﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Collections;

namespace TestesFixacao.WindowsApp
{
    public static class ListControlExtensions
    {
        /// <summary>
        /// Este método é responsável por sobrescrever todos os itens do list.
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="listControl"></param>
        /// <param name="sourceList"></param>
        public static void OverrideAll<T>(this IList listControl, IEnumerable<T> sourceList)
        {
            listControl.Clear();

            foreach (var item in sourceList)
            {
                if(item != null)
                    listControl.Add(item);
            }
        }
    }
}
